package com.grass;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * <p>类名称：ConsumeExampleServer
 * <p>描述说明：测试类
 * <p>版本号：2.0.0.0
 *
 * @author Alpho@方大侠
 * @date 2019/3/27 16:05
 */
@Service
public class ConsumeExampleServer {
    @Resource
    RestTemplate restTemplate;

    //Hystrix 服务降级，依赖隔离
    @HystrixCommand(fallbackMethod = "errorMsg")
    public String getProducers(){
        return restTemplate.getForObject("http://core/prints//hystrixs",String.class);
    }

    public String errorMsg(){
        return "The service is unavailable";
    }
}
